/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#ifndef OMEN_TIMER_H
#define OMEN_TIMER_H

#include "OmenConfig.h"
#include <IOmenTimer.h>

namespace Omen {

class OMEN_API Timer : public Omen::ITimer
{
    #define GUID_OMEN_TIMER "12DEA6D2-4C9A-47C3-AB63-03AD586AAFED"

public:
    virtual Omen_GUID classId() const { return OMEN_UUID(GUID_OMEN_TIMER); }    /// <summary>Defines the class ID</summary>

public:
    Timer();
    virtual ~Timer();

    virtual void start();               /// <summary>Starts the timer</summary>
    virtual void stop();                /// <summary>Stops the timer. Clears the counters</summary>
    virtual void pause();               /// <summary>Pauses the timer. Clears the counters</summary>

    virtual void initialize();          /// <summary>Initializes the timer, which clears the counters</summary>

    virtual bool running();             /// <summary>Returns true if the timer is running, false othersize</summary>

    virtual Omen::Float totalTime();    /// <summary>Returns the total time in seconds since the timer was started</summary>
    virtual Omen::Float elapsedTime(bool initTime = false);  /// <summary>Returns the elapsed time in seconds since the last query of elapsed time</summary>

protected:
    inline INT64 frequency();    /// <summary>Returns the timer frequency. THIS IS IMPLEMENTATION SPECIFIC value</summary>
    inline INT64 currentTime();  /// <summary>Returns the current system timer Time. THIS IS IMPLEMENTATION SPECIFIC value</summary>
    
    void updateElapsedTime();          /// <summary>Updates the timer value</summary>

private:
    bool            m_bRunning;
    bool            m_bTimerInitialized;

    INT64     m_initialTime;
    INT64     m_currentTime;
    INT64     m_previousTime;
    INT64     m_elapsedTime;

    Omen::Float     m_fElapsedTime;
    Omen::Float     m_fTotalTime;

}; // class Timer

} // namespace Omen

#endif // OMEN_TIMER_H

/// EOF